//
//  YFLoginViewController.m
//  SquashSpark
//
//  Created by Coollang on 2017/10/26.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "YFLoginViewController.h"

NSString *const loginSegue = @"LoginSegue";

@interface YFLoginViewController ()
@property (weak, nonatomic) IBOutlet UIButton *signUpButton;
@property (weak, nonatomic) IBOutlet UIButton *signInButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textImageTopCon;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomViewHeightCon;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textImageWidthCon;

@property (weak, nonatomic) IBOutlet UILabel *textLabel;
@property (weak, nonatomic) IBOutlet UIView *bottomView;

@end

@implementation YFLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kSeparationLineColor;
    [self adaptiveScreen];
    [UIView animateWithDuration:0.25 animations:^{
        [self.bottomView layoutIfNeeded];
    }];
    // Do any additional setup after loading the view.
}
- (IBAction)loginButtonClick:(UIButton *)sender {
    if (self.isGuideVc) {
        if (self.signButtonClickBlock) {
            self.signButtonClickBlock(sender.tag == 10 ? kLoginIn:kLoginUp);
        }
    }else {
        if (sender.tag == 10) {
            [self performSegueWithIdentifier:loginSegue sender:@(kLoginIn)];
        }else {
            [self performSegueWithIdentifier:loginSegue sender:@(kLoginUp)];
        }
    }
}

- (void)comeInLoginInOrLogupVc:(kLoginType)loginType {
    [self performSegueWithIdentifier:loginSegue sender:@(loginType)];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:loginSegue]) {
        YFLoginInAndUpVC *loginVc = (YFLoginInAndUpVC *)segue.destinationViewController;
        loginVc.loginType = [sender integerValue];
    }
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setHidden:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setHidden:NO];
}

//屏幕适配
- (void)adaptiveScreen {
    CGFloat screenWidth = MIN(kYFScreenWidth, kYFScreenHeight);
    CGFloat scale = screenWidth/375.0;
    self.textImageTopCon.constant = self.textImageTopCon.constant *scale;
    self.textImageWidthCon.constant = self.textImageWidthCon.constant * scale;
    if(self.isGuideVc){
        self.bottomViewHeightCon.constant = 0;
    }else {
        self.bottomViewHeightCon.constant = self.bottomViewHeightCon.constant * scale;
    }
    if (IS_IPAD) {
        self.textLabel.font = kOpenSansFont(OpenSansRegular, 26);
        self.signInButton.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 24);
        self.signUpButton.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 24);
    }else {
        self.textLabel.font = kOpenSansFont(OpenSansRegular, 15);
        self.signInButton.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 13);
        self.signUpButton.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 13);
    }
}


@end
